package app.qrcode.browser.hearttoheart.activities

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import app.qrcode.browser.hearttoheart.R
import app.qrcode.browser.hearttoheart.databinding.ActivityPrepareTeacherBinding
import app.qrcode.browser.hearttoheart.fragments.TeacherDiscussionFragment
import app.qrcode.browser.hearttoheart.fragments.TeacherGroupFragment
import com.google.android.material.tabs.TabLayoutMediator

class PrepareTeacherActivity : AppCompatActivity() {

    private lateinit var binding: ActivityPrepareTeacherBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityPrepareTeacherBinding.inflate(layoutInflater)
        setContentView(binding.root)
        binding.lessonPrepareViewpager2.adapter = object : FragmentStateAdapter(this) {


            override fun getItemCount(): Int = 2


            override fun createFragment(position: Int): Fragment =
                when (position) {
                    0 -> TeacherGroupFragment()
                    else -> TeacherDiscussionFragment()
                }
        }
        TabLayoutMediator(
            binding.tabLayoutTeacher,
            binding.lessonPrepareViewpager2
        ) { tab, position ->
            when (position) {
                0 -> tab.text = "小组"
                else -> tab.text = "论坛"
            }
        }.attach()
    }
}